{% load form_helpers %}

<div class="mb-10 d-md-flex justify-content-center{% if field.errors %} has-error{% endif %}">
    {% if field|widget_type == 'checkboxinput' %}
        <div class="col-md-9 offset-md-3">
            <div class="form-check mt-6{% if field.errors %} has-error{% endif %}">
                {{ field }}
                <label class="form-check-label" for="{{ field.id_for_label }}">
                    {{ field.label }}
                </label>
            </div>
            {% if bulk_nullable %}
                <div class="form-check mt-6">
                    <input class="form-check-input" id="{{ field.id_for_label }}_nullify" name="_nullify" type="checkbox" value="{{ field.name }}">
                    <label class="form-check-label" for="{{ field.id_for_label }}_nullify">Set null</label>
                </div>
            {% endif %}
            {% if field.help_text %}
                <span class="form-text">{{ field.help_text|safe }}</span>
            {% endif %}
    {% elif field|widget_type == 'textarea' and not field.label %}
        <div class="col-md-12">
            {{ field }}
            {% if bulk_nullable %}
                <div class="form-check mt-6">
                    <input class="form-check-input" id="{{ field.id_for_label }}_nullify" name="_nullify" type="checkbox" value="{{ field.name }}">
                    <label class="form-check-label" for="{{ field.id_for_label }}_nullify">Set null</label>
                </div>
            {% endif %}
            {% if field.help_text %}
                <span class="form-text">{{ field.help_text|safe }}</span>
            {% endif %}
    {% else %}
        <label class="col-md-3 col-form-label{% if field.field.required %} nb-required{% endif %}" for="{{ field.id_for_label }}">
            {{ field.label }}
        </label>
        <div class="col-md-9">
            {{ field }}
            {% if bulk_nullable %}
                <div class="form-check mt-6">
                    <input class="form-check-input" id="{{ field.id_for_label }}_nullify" name="_nullify" type="checkbox" value="{{ field.name }}">
                    <label class="form-check-label" for="{{ field.id_for_label }}_nullify">Set null</label>
                </div>
            {% endif %}
            {% if field.help_text %}
                <span class="form-text">{{ field.help_text|safe }}</span>
            {% endif %}
    {% endif %}
    {% if field.errors %}
        <ul class="mb-0 mt-4">
            {% for error in field.errors %}
                {# Embed an HTML comment indicating the error for extraction by tests #}
                <!-- FORM-ERROR {{ field.name }}: {{ error }} -->
                <li class="text-danger">{{ error }}</li>
            {% endfor %}
        </ul>
    {% endif %}
</div>
</div>
